/**
 * Copyright (c) 2010 - 2018 Allinpay. All rights reserved.
 */
package com.allinpay.springBoot.springboot.controller;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.MessageSource;
import org.springframework.validation.BindingResult;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.allinpay.mcp.commons.base.ResponseMsg;
import com.allinpay.springBoot.springboot.controller.dto.req.QueryOrder;
import com.allinpay.springBoot.springboot.dao.pojo.HdOrderInfo;
import com.allinpay.springBoot.springboot.serivce.HdOrderInfoSerivce;
import com.allinpay.springBoot.springboot.util.RedisService;

/**
 * TODO:
 *
 * @author tangjun
 * @date 2018-08-10
 */

@RestController
@RequestMapping("/hd/order")
public class HdOrderController {

	@Autowired
	private HdOrderInfoSerivce hdOrderInfoSerivce;

	@Resource
	private MessageSource messageSource;

	@Autowired
	private RedisService redisService;

	// @RequestParam(name = "orderId") String orderId
	@RequestMapping("/list")
	public ResponseMsg<HdOrderInfo> list(@RequestParam(name = "orderId") String orderId) {
		HdOrderInfo dasdsa = hdOrderInfoSerivce.list(orderId);

		// boolean set = redisService.set("001", list, 100L);
		// boolean exists = redisService.exists("001");
		// if (exists) {
		// System.out.println("redis已经存在");
		// } else {
		// System.out.println("redis不存在");
		// }

		return new ResponseMsg<HdOrderInfo>("0000000", "成功", dasdsa);
	}

	@RequestMapping("/pageList")
	public ResponseMsg<List<HdOrderInfo>> pageList(@Validated @RequestBody QueryOrder req, BindingResult bindingResult) {
		
		List<HdOrderInfo> pageList = hdOrderInfoSerivce.pageList(req.getOrderId());

		return new ResponseMsg<List<HdOrderInfo>>("0000000", "成功", pageList);
	}
}
